import JSEncrypt from './jsencrypt'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzhCbgoF2O4z0urtC6LXMUq4ngH4w8WlUu62FxcVw4VHBWLO6ZG4Bu+PPaFt2E6Z8F6AISDmHIEVFbp+hLMpmZCRoE7DTqErFFKkcIRJq3rcxBKG2AizK1FtvBPZYeHdWhEwuJK/SiFDlGM2ih2ctf8O/QUq/ljGqGbXEbvmYeGQIDAQAB'

const privateKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALOEJuCgXY7jPS6u0LotcxSrieAfjDxaVS7rYXFxXDhUcFYs7pkbgG7489oW3YTpnwXoAhIOYcgRUVun6EsymZkJGgTsNOoSsUUqRwhEmretzEEobYCLMrUW28E9lh4d1aETC4kr9KIUOUYzaKHZy1/w79BSr+WMaoZtcRu+Zh4ZAgMBAAECgYB3gQYQizE9KfFU3nN9PTxbCkbiuJ22n7wNXAymZHyr0yplc8vyiOha98f96zLUhGGkoOqf8osNkNnEVmbBiJHOvVakVtpoQ8s5M+lV+KfdlA3dtv/mTyUBkYO/9d5N0Bi43pZqnLHy/JskGLtPrGipg0JNNva4mDricadhxcyDMQJBANnnaq6cK64n882A2vRSCjmzhYtNcxUxU9PVSzt9g+nFJ5L9WxHSh20OKBuLZOpz71a64pgZ5fkm2/OTi1396EsCQQDS5qPU4CvxddS2TT4VdFIgrvAdGp+BEHe7frfz4fygmoa98/qulcWaGyErLzhuG3u0ZtNW/4b8jxwqzctyU1yrAkEAlbT6hJBjKjnktNHMnIMo50/Bdl11rZ/AOg+Wqn6nfJqpf8F1Kh98T56kS5hPcwzH6MxpFZrld3INN6Gs5JynVQJAI4Bfo734p7TGEcn+4W2rRYUtNjj9EKTNAurZ3Fv2QrLAa8leMXVUxhQ7CSHxxdcqg7urZ8Gr32fXvfzWenA98QJANZONYfMTc0wk7rBk6UYLXp/Lr0LLD3Hohbjsan69pjyrYDb5qVcTf/g4Iv65RZzm5UHbdrh8J6rFS7VlSWXVRQ==';

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}

